# 可进行模糊查询，语法至少支持下面3种:
# 　　select name,age from staff_table where age > 22
# 　　select  * from staff_table where dept = "IT"
#    select  * from staff_table where enroll_date like "2013"
#    查到的信息，打印后，最后面还要显示查到的条数
# 可创建新员工纪录，以phone做唯一键，staff_id需自增
# 可删除指定员工信息纪录，输入员工id，即可删除
# 可修改员工信息，语法如下:
# 　　UPDATE staff_table SET dept="Market" WHERE where dept = "IT"

#_*_conding:utf-8_*_


def sql_stat(sql):
    first_list = {
        "select":select,
        "update":update,
        "insert":insert,
        "delete":delete
    }
    stat = sql.split(' ')
    first = stat[0]
    res = ''
    if first in first_list:
        res = first_list[first](stat)
    return res

def select(select_stat):
    select_dic = {
        'first':select_l,
        'select':[],
        'from':[],
        'where':[]
    }
    return total(select_stat,select_dic)

def update(update_stat):

    pass

def insert(insert_stat):

    pass

def delete(delete_stat):

    pass

def total(stat,first_list):
    key={}
    for item in stat:
        if item in first_list:
            key = item
            continue
        else:
            first_list[key].append(item)
    return first_list
    print(first_list)

def sql_action(sql_dic):
    return sql_dic.get('first')(sql_dic)

def select_l(sql_dic):
    table = sql_dic.get('from')[0]
    f=open("staff_table","r",encoding="utf-8")
    where_res = where_serch(f,sql_dic.get("where"))

    pass

def where_serch(f,where_l):
    pass

def update_l():
    pass

def insert_l():
    pass

def delete_l():
    pass

while True:
    sql = input('sql>').strip()
    if sql == "exit":break
    if len(sql) == 0 : continue
    sql_dic = sql_stat(sql)
    if len(sql_dic) == 0 : continue
    res = sql_action(sql_dic)







